<template>
	<view>
		<video :src="videosrc1"></video>
		<view>视频时间{{ dataVideo1.duration }}</view>
		<view>视频高度{{ dataVideo1.height }}</view>
		<view>视频宽度{{ dataVideo1.width }}</view>
		<view>视频路径{{ dataVideo1.tempFilePath }}</view>
		<view style="margin-top: 40rpx;">视频额外详细信息:{{datainfo.errMsg}}</view>
		<button type="default" @click="video1" size="mini">拍摄视频或从手机相册中选视频放到页面</button>

		<view style="border: 2px solid orange;"></view>

		<video :src="videosrc2"></video>
		<view>视频时间{{ dataVideo2.duration }}</view>
		<view>视频高度{{ dataVideo2.height }}</view>
		<view>视频宽度{{ dataVideo2.width }}</view>
		<view>视频路径{{ dataVideo2.tempFilePath }}</view>
		<button type="default" @click="video2" size="mini">拍摄视频或从手机相册中选视频放到页面，并保存视频到系统相册。</button>
	</view>
</template>

<script>
export default {
	data() {
		return {
			videosrc1: '',
			dataVideo1: {},
			datainfo: {},

			videosrc2: '',
			dataVideo2: {},
		};
	},
	methods: {
		video1() {
			let _this = this;
			uni.chooseVideo({
				sourceType: ['camera', 'album'],
				success: function(res) {
					_this.dataVideo1 = res;
					_this.videosrc1 = res.tempFilePath;
					
					uni.getVideoInfo({//查询视频详细信息
						src:res.tempFilePath,
						success:function(res){
							_this.datainfo = res
						},
						fail:function(err){
							_this.datainfo = err
						},
						
					})
				}
			});
		},
		video2() {
			var _this = this;
			uni.chooseVideo({
				sourceType: ['camera'],
				success: function(res) {
					console.log(res);
					_this.dataVideo2 = res;
					_this.videosrc2 = res.tempFilePath;

					uni.saveVideoToPhotosAlbum({
						filePath: res.tempFilePath,
						success: function() {
							console.log('save success');
						}
					});
				}
			});
		}
	}
};
</script>

<style></style>
